package com.citywithincity.pay;

import java.io.IOException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

/**
 * 支付接口
 * @author Randy
 *
 */
public interface IPay {
	/**
	 * 外部订单
	 */
	public static final String ORDER_ID = "orderId";
	
	/**
	 * 
	 */
	public static final String PLAT_ORDER_ID = "platId";

	
	/**
	 * 预支付
	 * @param outID				外部id，由本系统生成
	 * @param title				标题
	 * @param fee				总价格(单位分)
	 * 
	 * @param ip				客户端ip地址
	 * @return					由各个具体pay制定
	 * @throws PayException		业务错误,需要通知用户知道
	 * @throws IOException		网络错误，需要重新执行
	 */
	Object prePay(
			SysOrder order,
			String outID,
			String title,
			int fee,
			int businessId,
			int type,
			String channel,
			HttpServletRequest request) throws PayException,IOException;
	
	/**
	 * 退款
	 * @param orderID
	 * @param refundID
	 * @param fee
	 * @param isOutID
	 * @return
	 * @throws PayException
	 */
	boolean refund(SysOrder order,String outID,String refundID, int fee,boolean isOutID) throws PayException,IOException ;
	
	/**
	 * 查询支付状态
	 * @param orderID
	 * @param isOutID
	 * @return
	 * @throws PayException
	 * @throws IOException
	 */
	PayStatus queryStatus(String orderID,SysOrder order,boolean isOutID) throws PayException, IOException;
	
	
	OrderInfo queryOrder(SysOrder order,String orderID,boolean isOutID) throws PayException,IOException;
	
	/**
	 * 客户端提交信息的验证
	 * @param content
	 * @param deviceID
	 * @return
	 */
	boolean clientVerify(String content,String deviceID);

	/**
	 * 
	 * @param request
	 * @return
	 */
	OrderInfo parseOrder(HttpServletRequest request) throws IOException,PayException;
	
	
	/**
	 * 查询客户端通知的订单状态
	 * @param id
	 * @param json
	 * @return
	 */
	PayStatus queryClientNotifyOrderStatus(String id,SysOrder order, Map<String, Object> json)  throws PayException, IOException;

	
	
}
